package com.deepinblog.mongodbdemo.controller;

import com.deepinblog.mongodbdemo.bean.Edge;
import com.deepinblog.mongodbdemo.bean.Result;
import com.deepinblog.mongodbdemo.bean.neo4j.Person;
import com.deepinblog.mongodbdemo.service.Neo4jPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by louisyuu on 2020/7/11 6:22 PM
 */

@Controller
public class Neo4jController {


    @Autowired
    private Neo4jPersonService neo4jPersonService;



    @RequestMapping("/get")
    @ResponseBody
    public Result get(){
        List<Person> all = neo4jPersonService.getAll();
        List<String> nodes = new ArrayList<>();

        List<Edge> edges = new ArrayList<>();

        edges.add(new Edge(1,2));
        edges.add(new Edge(1,2));
        edges.add(new Edge(1,2));
        edges.add(new Edge(1,2));
        edges.add(new Edge(1,2));
        edges.add(new Edge(1,2));
        edges.add(new Edge(1,2));
        edges.add(new Edge(1,2));


        all.forEach(e->nodes.add(e.getName()));





        return new Result(nodes,edges);
    }



    @RequestMapping("/neo4j")
    public String index(){
        return "neo4j";
    }

}
